package sg.edu.nus.iss.vmcs.service;

import sg.edu.nus.iss.vmcs.machinery.MachinerySimulatorPanel;
/**
 * Implementor class for the machinery display service
 * @author User
 *
 */
public class MachineryDisplayService implements IMachineryDisplayService{
	
	private MachinerySimulatorPanel machinerySimulatorPanel;
	private static MachineryDisplayService instance;
	
	/**
	 * Return new Machinery Simulator Panel display service
	 * @return
	 */
	public static MachineryDisplayService getInstance(){
		
		if(instance==null){
			instance = new MachineryDisplayService();
		}
	
		return instance;
	}
	/**
	 * Get the machinary control panel
	 * @return
	 */
	public MachinerySimulatorPanel getMachinerySimulatorPanel() {
		return machinerySimulatorPanel;
	}
	/**
	 * Set the machinary simulator panel
	 * @param machinarySimulatorPanel
	 */
	public void setMachinerySimulatorPanel(
			MachinerySimulatorPanel machinarySimulatorPanel) {
		this.machinerySimulatorPanel = machinarySimulatorPanel;
	}
	/**
	 * Close down the machinary simulator panel
	 */
	public void closeDownMachineryPanel(){
		if (machinerySimulatorPanel != null)
			machinerySimulatorPanel.dispose();
	}
	/**
	 * Display the machinary panel
	 */
	public void displayMachineryPanel(){
		machinerySimulatorPanel.display();
	}
	/**
	 * Dispose the machinary panel
	 */
	public void disposeMachineryPanel(){
		machinerySimulatorPanel.dispose();
	}
	/**
	 * Check if the machinary panel terminated
	 * @return
	 */
	public boolean isMachineryPanelTerminated(){
		return (machinerySimulatorPanel==null);
	}
	/**
	 * Set the door state of the machinary panel
	 * @param doorState
	 */
	public void setDoorState(boolean doorState){
		machinerySimulatorPanel.setDoorState(doorState);
	}
	/**
	 * Update the drink store display
	 */
	public void updateDrinkStoreDisplay(){
		machinerySimulatorPanel.getDrinksStoreDisplay().update();
	}
	/**
	 * Update the cash store display
	 */
	public void updateCashStoreDisplay(){
		machinerySimulatorPanel.getCashStoreDisplay().update();
	}
	/**
	 * Refresh the machinary simulation panel
	 */
	public void refreshMachinerySimulationPanel(){
		machinerySimulatorPanel.refresh();
	}
}
